﻿@model Occupie.Models.Student

@if (Model.Languages == null || Model.Languages.Count == 0)
{
    <p>Все още не си добавил никакви езици!</p>
}
else
{
    for (int i = 0; i < Model.Languages.Count; i++)
    {
    <div id="language@(i)" class="lang-item">
        <div class="editor-label">
            @Html.LabelFor(model => model.Languages[i].Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Languages[i].Name)
            @Html.ValidationMessageFor(model => model.Languages[i].Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Languages[i].Proficiency)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Languages[i].Proficiency, new SelectList(Occupie.Utilities.GetProficiencies(), "Value", "Text", Model.Languages[i].Proficiency))
            @Html.ValidationMessageFor(model => model.Languages[i].Proficiency)
        </div>

        <div class="dialog" id="delLangDialog" style="display: none;"></div>

        <div class="del-link">
            @Ajax.ActionLink("Изтрий", "DeleteLanguage", "Language", new { langId = Model.Languages[i].LangId, listId = i }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "delLangDialog", InsertionMode = InsertionMode.Replace, OnSuccess = "openDelLangPopup()" })<br />
        </div>
    </div> 
       
        if ((i + 1) % 3 == 0)
        {
            <div style="clear: both"></div>
            <hr class="full-hr" />
        }
    }
}

<script>
    $(document).ready(function () {
        $("#delLangDialog").dialog(
            {
                autoOpen: false,
                width: 300,
                height: 'auto',
                modal: true,
            }
        );
    });

    function openDelLangPopup() {
        $("#delLangDialog").dialog().dialog("open");
    }
</script>
